<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" xmlns:th="http://www.thymeleaf.org">
    <title>Title</title>
    <script src="/js/jquery.js"></script>
</head>
<body>

<form action="/cx" method="post">
    <input type="text" name="name" th:value="${bookname}">
    <input type="submit" value="查询">
</form>

<a th:href="@{/add1}"><button>新增</button></a>

<form action="/delby" method="post" onsubmit="return x()">
    <input type="submit" value="批量删除">
<table border="1px">
    <tr>
        <td>选中</td>
        <td>编号</td>
        <td>书名</td>
        <td>价格</td>
        <td>类目</td>
        <td>库存</td>
        <td>图片</td>
        <td>说明</td>
        <td>作者</td>
        <td>已售</td>
        <td>操作</td>
    </tr>
    <tr th:each="book:${page.records}">
        <td><input type="checkbox" name="id" th:value="${book.id}"></td>
        <td th:text="${book.id}"></td>
        <td th:text="${book.name}"></td>
        <td th:text="${book.price}"></td>
        <td th:text="${book.category}"></td>
        <td th:text="${book.pnum}"></td>
        <td th:text="${book.imgurl}"></td>
        <td th:text="${book.description}"></td>
        <td th:text="${book.author}"></td>
        <td th:text="${book.sales}"></td>
        <td><a th:text="删除" th:href="@{/del(id=${book.id})}" ></a> <a th:text="修改" th:href="@{/update(id=${book.id})}" ></a></td>
    </tr>
</table>
</form>

    <span>总页数:<span th:text="${page.getPages}"></span></span>
<span>总条数:<span th:text="${page.getTotal}"></span></span>
    <span th:if="${page.hasPrevious()}">
        <a th:href="@{/page(name=${bookname},pagenum=${page.current -1})}">上一页</a>
    </span>
    <span th:if="${page.hasNext()}">
        <a th:href="@{/page(name=${bookname},pagenum=${page.current+1})}">下一页</a>
    </span>
    <span th:each="p:${#numbers.sequence(1,page.pages)}">
        <a th:href="@{/page(name=${bookname},pagenum=${p})}" th:text="${p}"></a>
    </span>


</body>

<script>
    function x(){
        if ($("[name=id]:checked").length==0){
           alert("请选择数据")
            return false;
        }
        else if (confirm("确认删除数据吗?")){

        }
        else {
            return false;
        }
    }
</script>

</html>